package com.naodong.shenluntiku.util;

/**
 * Created by hujie on 16/5/25.
 */
public class TimeUtil {


    /**
     * 计时格式化为HH:MM:SS
     * @param miss
     * @return
     */
    public static String formatMiss(int miss) {
        String hh = miss / 3600 > 9 ? miss / 3600 + "" : "0" + miss / 3600;
        String mm = (miss % 3600) / 60 > 9 ? (miss % 3600) / 60 + "" : "0" + (miss % 3600) / 60;
        String ss = (miss % 3600) % 60 > 9 ? (miss % 3600) % 60 + "" : "0" + (miss % 3600) % 60;
        return hh + ":" + mm + ":" + ss;
    }


    /**
     * 计时格式化为HH:MM:SS 或者mm:ss
     * @param miss
     * @return
     */
    public static String formatMiss1(int miss) {
        miss = miss / 1000;
        String hh = miss / 3600 > 9 ? miss / 3600 + "" : "0" + miss / 3600;
        String mm = (miss % 3600) / 60 > 9 ? (miss % 3600) / 60 + "" : "0" + (miss % 3600) / 60;
        String ss = (miss % 3600) % 60 > 9 ? (miss % 3600) % 60 + "" : "0" + (miss % 3600) % 60;
        if (hh.equals("00")) {
            return mm + ":" + ss;
        }
        return hh + ":" + mm + ":" + ss;
    }

    /**
     * 秒转分钟
     * @param second
     * @return
     */
    public static int secondToMinute(int second) {
        return second / 60;
    }
}
